import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_liquid_glass/liquid_glass.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:sinosheets/components/NetWorkImage/NetworkImageWidget.dart';
// import 'package:sinosheets/components/normal_product_alert.dart';
import 'package:sinosheets/route/route_utils.dart';
import 'package:sinosheets/utils/theme/style_utils.dart';
// import 'package:sinosheets/utils/toast_util.dart';

class NormalProductItem extends StatelessWidget {
  final Map item;
  const NormalProductItem({super.key, required this.item});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        // launchUrl(Uri.parse('${AppPrefix.urlPrefix}/product-detail?url=${Uri.encodeComponent(item['detailUrl'])}'));
        // RouteUtils.toWebView(url: "${AppPrefix.urlPrefix}/product-detail?url=${Uri.encodeComponent(item['detailUrl'])}");
        // NormalProductAlert.show(productInfo: item);
        RouteUtils.toProductDetail(item);
      },
      child: LiquidGlassContainer(
        config: LiquidGlassConfig(
          baseColor: Colors.white,
          opacity: 0.1,
          blurAmount: 20,
          borderRadius: BorderRadius.circular(12.r),
          enableSpecularHighlight: true,
          gradient: LinearGradient(
            colors: [
              Colors.white.withValues(alpha: 0.1),
              Colors.white.withValues(alpha: 0.1),
            ],
          ),
          shadows: [
            BoxShadow(
              color: Colors.white.withValues(alpha: 0.2),
              blurRadius: 20,
              offset: const Offset(0, 10),
            ),
          ],
        ),
        child: Container(
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(12.r),
            boxShadow: [
              BoxShadow(
                color: Colors.black.withOpacity(0.05),
                blurRadius: 8.r,
                offset: Offset(0, 2.r),
              ),
            ],
          ),
          child: Stack(
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Center(
                    child: ClipRRect(
                      borderRadius: BorderRadius.circular(12.r),
                      child: NetworkImageWidget(
                        url: item['img'],
                        width: double.infinity,
                        height: 180.r,
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                  Padding(
                      padding: EdgeInsets.symmetric(horizontal: 10.r),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          SizedBox(height: 12.r),
                          Text(
                            item['itemName'] ?? '',
                            style: TextStyle(fontSize: 13.r, color: Color(0xFF333333)),
                            maxLines: 2,
                            overflow: TextOverflow.ellipsis,
                          ),
                          SizedBox(height: 8.r),
                          Row(
                            children: [
                              Text('${item['price']} ${item['symbol']}', style: TextStyle(color: Color(0xFFFF7D00), fontSize: 14.r, fontWeight: FontWeight.bold)),
                              SizedBox(width: 6.r),
                              Text('${item['crossedPrice']} ${item['symbol']}', style: TextStyle(color: ColorUtils.c_666666, fontSize: 10.r, decoration: TextDecoration.lineThrough)),
                            ],
                          ),
                          SizedBox(height: 10.r),
                        ],
                      ))
                ],
              ),
              // 左上角标签
              // Positioned(
              //   left: 0,
              //   top: 0,
              //   child: GestureDetector(
              //     onTap: () {
              //       //复制
              //       Clipboard.setData(ClipboardData(text: '${item['inId']}'));
              //       ToastUtil.showText('Copied');
              //     },
              //     child: Container(
              //       padding: EdgeInsets.symmetric(horizontal: 10.r, vertical: 4.r),
              //       decoration: BoxDecoration(
              //         color: Color(0xFFFF7D00),
              //         borderRadius: BorderRadius.only(
              //           topLeft: Radius.circular(12.r),
              //           bottomRight: Radius.circular(8.r),
              //         ),
              //       ),
              //       child: Text(
              //         "${item['inId']}",
              //         style: TextStyle(color: Colors.white, fontSize: 13.r, fontWeight: FontWeight.bold),
              //       ),
              //     ),
              //   ),
              // ),
            ],
          ),
        ),
      ),
    );
  }
}
